<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

<title><?= $event_data['name'] ?></title>

<link href="__PUBLIC__/plugins/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<link href="__PUBLIC__/themes/global/global.css" rel="stylesheet">
<link href="__PUBLIC__/themes/wechat/treasure/style.css" rel="stylesheet">
<link href="__PUBLIC__/themes/wechat/treasure/patch.css" rel="stylesheet">
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="__PUBLIC__/plugins/jquery/2.1.3/jquery.min.js"></script>
<script src="__PUBLIC__/plugins/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="__PUBLIC__/js/global.js"></script>
<script src="__PUBLIC__/js/wechat/treasure/rule.js"></script>
<script>
var Param = <?= json_encode($param) ?> ;
$(function(){
  Rule.init(<?= json_encode($config) ?>);
});

var share_data = <?= json_encode($share_data) ?> ;
wx.config({
    debug   : false ,
    appId   : '<?php echo $wx_js_config["appid"]; ?>' ,
    timestamp: <?php echo $wx_js_config["timestamp"]; ?>,
    nonceStr: '<?php echo $wx_js_config["noncestr"];?>',
    signature: '<?php echo $wx_js_config["signature"];?>',
    jsApiList: [
      'onMenuShareTimeline' ,
      'onMenuShareAppMessage',
      'onMenuShareQQ' ,
      'onMenuShareWeibo'
    ]
});

wx.ready(function () {
  wx.onMenuShareTimeline({
    title : share_data.title, // 分享标题
    link  : share_data.link, // 分享链接
    desc  : share_data.desc , // 分享描述
    imgUrl: share_data.icon, // 分享图标
    success: function () { 
      // 用户确认分享后执行的回调函数
      //alert( share_data.link);
    },
    cancel: function () { 
      //用户取消分享后执行的回调函数
    }
  });
  
  wx.onMenuShareAppMessage({
    title: share_data.title, // 分享标题
    desc : share_data.desc , // 分享描述
    link : share_data.link, // 分享链接
    imgUrl:  share_data.icon, // 分享图标
    type: 'link', // 分享类型,music、video或link，不填默认为link
    dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
    success: function () { 
      // 用户确认分享后执行的回调函数
    },
    cancel: function () { 
      // 用户取消分享后执行的回调函数
    }
  });
      
  wx.onMenuShareQQ({
    title: share_data.title, // 分享标题
    desc: share_data.desc, // 分享描述
    link: share_data.link, // 分享链接
    imgUrl: share_data.icon, // 分享图标
    success: function () { 
      // 用户确认分享后执行的回调函数
      //alert(share_data.url);
    },
    cancel: function () { 
      // 用户取消分享后执行的回调函数
    }
  });
  wx.onMenuShareWeibo({
    title: share_data.title, // 分享标题
    desc: share_data.desc, // 分享描述
    link: share_data.link , // 分享链接
    imgUrl: share_data.icon , // 分享图标
    success: function () { 
      // 用户确认分享后执行的回调函数
    },
    cancel: function () { 
      // 用户取消分享后执行的回调函数
    }
  });
});
</script>
</head>
<body>

<div class="container rule">
  <!--
  <a href="#" id="load_take_award_btn">测试1</a>
  -->
  <div class="rule-text-line">
    <div class="content"><?= $event_data['rule'] ?></div>
  </div>
  <div class="rule-award-line">
    <div class="banner"></div>
    <div class="content">
      <table width="100%" border="0" cellpadding="6" cellspacing="0" >
        <tbody>
          <tr>
            <th width="20%" scope="col">产品名称</th>
            <th width="30%" scope="col">需要元宝</th>
            <th width="30%" scope="col">剩余/总数量</th>
            <th scope="col">&nbsp;</th>
          </tr>
          <?php foreach( $award_data as $key => $row ) : ?>
          <tr>
            <td><img src="__PUBLIC__/themes/wechat/treasure/images/award_<?= $row['id'] ?>.jpg"></td>
            <td><?= $row['point'] ?></td>
            <td><?= $row['remain_qty']?>/<?= $row['total_qty']?></td>
            <td><a class="award_btn" href="#" data-id="<?= $row['id']?>" data-remain="<?= $row['remain_qty']?>" data-name="<?= $row['name']?>" data-point="<?= $row['point']?>">兑换</a></td>
          </tr>
          <?php endforeach; ?>
        </tbody>
      </table>
    </div>
    <div class="rule-btn-line">
      <a id="load_my_award_btn" href="#" class="img-btn rule-my-award-btn">我的奖品</a>
      <a href="javascript:history.go(-1)" class="img-btn rule-back-btn">返回</a>
    </div> 
  </div>

</div>

<div id="my_award_modal" class="my-award-modal">
  <table>
    <tr>
      <td width="90"><?= $config['event_user']['award_name']?></td>
      <td width="70"><?= substr($config['event_user']['award_time'] , 5 , 5 ) ?></td>
      <td><?= $config['event_user']['award_sn']?></td>
    </tr>
  </table>
  <a class="close-btn" href="#">close</a>
</div>

<div id="take_award_modal" class="take-award-modal">
  <a class="close-btn" href="#">close</a>
  <div id="award_name">手机</div>
  <a class="rule-share-btn" id="share_btn" href="#">告诉小伙伴</a>
</div>

<div id="share_modal" class="share-modal">
  <img src="__PUBLIC__/themes/wechat/treasure/images/share_arrow.png">
</div>

</body>
</html>